import { GCellRenderer } from "../../../../com/mui/controls/GCellRenderer";
import { ObjCreate } from "../common/ObjCreate";
import { ItemInfo } from "../../resource/info/ItemInfo";
import { SearchConditionData } from "./SearchConditionData";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
//class SearchStringRenderer
    
    export  class SearchStringRenderer extends GCellRenderer
    {
        constructor()
        {
            super();
            addEventListener(flash.events.MouseEvent.CLICK, this.onMouseClickHandler);
            addEventListener(flash.events.MouseEvent.ROLL_OVER, this.onMouseOverHandler);
            addEventListener(flash.events.MouseEvent.ROLL_OUT, this.onMouseOutHandler);
            return;
        }

        protected /* override */ configUI(): void
        {
            this._text = ObjCreate.createTextField("", 5, 0, 120, 20, this);
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            super.data = arg1;
            if (arg1 == null) 
            {
                this._text.text = "";
            }
            else 
            {
                this._itemInfo = arg1.itemInfo as ItemInfo;
                this._text.htmlText = this._itemInfo.htmlName;
            }
            return;
        }

        /* internal  */onMouseClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=new Map<any, any> /* flash.utils.Dictionary */();
            loc1[this._itemInfo.item.code] = this._itemInfo.item.code;
            SearchConditionData.codesMap = loc1;
            Dispatcher.dispatchEvent(new DataEvent(EventName.MarketSearchItemSelect, this._itemInfo));
            return;
        }

        /* internal  */onMouseOverHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            graphics.lineStyle(1, 65407, 1);
            graphics.moveTo(3, 0);
            graphics.lineTo(this.width - 3, 0);
            graphics.moveTo(3, this.height - 2);
            graphics.lineTo(this.width - 6, this.height - 2);
            return;
        }

        /* internal  */onMouseOutHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            graphics.clear();
            return;
        }

        /* internal */ /* var */_text: Object /* flash.text.TextField */;

        /* internal */ /* var */_itemInfo: ItemInfo;
    }
